//package com.infoland.afanmall.base.util;
//
//import android.content.Context;
//import android.support.annotation.NonNull;
//import android.support.design.widget.CoordinatorLayout;
//import android.support.v7.widget.Toolbar;
//import android.util.AttributeSet;
//import android.util.Log;
//import android.view.View;
//import android.widget.Toast;
//
////
//////import android.content.Context;
//////import android.support.annotation.NonNull;
//////import android.support.design.widget.CoordinatorLayout;
//////import android.support.v7.widget.Toolbar;
//////import android.util.AttributeSet;
//////import android.view.View;
////
////
/////**
//// * Created by 傅令杰
//// */
////
//import com.infoland.afanmall.R;
//
//@SuppressWarnings("unused")
//public final class TranslucentBehavior extends CoordinatorLayout.Behavior<Toolbar> {
//    private static final String TAG = "TranslucentBehavior...";
//    private Context context;
//    //注意这个变量一定要定义成类变量
//    private int mOffset = 0;
//    //延长滑动过程
//    private static final int MORE = 100;
//
//    //
//    public TranslucentBehavior(Context context, AttributeSet attrs) {
//        super(context, attrs);
//        this.context = context;
//
//    }
//
//    @Override
//    public boolean layoutDependsOn(CoordinatorLayout parent, Toolbar child, View dependency) {
//        return dependency.getId() == R.id.tb2_index;
////        return super.layoutDependsOn(parent, child, dependency);
//    }
//
//    //
////
//    @Override
//    public boolean onStartNestedScroll(
//            @NonNull CoordinatorLayout coordinatorLayout
//            , @NonNull Toolbar child
//            , @NonNull View directTargetChild
//            , @NonNull View target
//            , int axes
//            , int type) {
//        return true;
//    }
//
//    //
//    @Override
//    public void onNestedScroll(
//            @NonNull CoordinatorLayout coordinatorLayout
//            , @NonNull Toolbar toolbar
//            , @NonNull View target
//            , int dxConsumed
//            , int dyConsumed
//            , int dxUnconsumed
//            , int dyUnconsumed
//            , int type) {
//        Log.e(TAG, "  " + dxConsumed + "  " + dyConsumed + "  " + dxUnconsumed + "  " + dyUnconsumed);
//        final int startOffset = 0;
//        final int endOffset = this.context.getResources().getDimensionPixelOffset(R.dimen.dp_80) + MORE;
//        mOffset += dyConsumed;
//        if (mOffset <= startOffset) {
//            toolbar.getBackground().setAlpha(0);
//        } else if (mOffset > startOffset && mOffset < endOffset) {
//            final float percent = (float) (mOffset - startOffset) / endOffset;
//            final int alpha = Math.round(percent * 255);
//            toolbar.getBackground().setAlpha(alpha);
//        } else if (mOffset >= endOffset) {
//            toolbar.getBackground().setAlpha(255);
//        }
//    }
//}
